from abc import abstractmethod, ABC

from base.java.Objects import Objects


class Iterator(ABC):

    @abstractmethod
    def hasNext(self):
        pass

    @abstractmethod
    def next(self):
        pass

    @abstractmethod
    def remove(self):
        pass

    def forEachRemaining(self, action):
        Objects.requireNonNull(action, 'action can not be null')
        while self.hasNext():
            action(self.next())

